package com.ruoyi.finance.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.finance.domain.Distributorapp;
import com.ruoyi.finance.service.IDistributorappService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 分销员申请表Controller
 * 
 * @author ruoyi
 * @date 2025-06-11
 */
@RestController
@RequestMapping("/distributorapp/distributorapp")
public class DistributorappController extends BaseController
{
    @Autowired
    private IDistributorappService distributorappService;

    /**
     * 查询分销员申请表列表
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:list')")
    @GetMapping("/list")
    public TableDataInfo list(Distributorapp distributorapp)
    {
        startPage();
        List<Distributorapp> list = distributorappService.selectDistributorappList(distributorapp);
        return getDataTable(list);
    }

    /**
     * 导出分销员申请表列表
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:export')")
    @Log(title = "分销员申请表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Distributorapp distributorapp)
    {
        List<Distributorapp> list = distributorappService.selectDistributorappList(distributorapp);
        ExcelUtil<Distributorapp> util = new ExcelUtil<Distributorapp>(Distributorapp.class);
        util.exportExcel(response, list, "分销员申请表数据");
    }

    /**
     * 获取分销员申请表详细信息
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(distributorappService.selectDistributorappById(id));
    }

    /**
     * 新增分销员申请表
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:add')")
    @Log(title = "分销员申请表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Distributorapp distributorapp)
    {
        return toAjax(distributorappService.insertDistributorapp(distributorapp));
    }

    /**
     * 修改分销员申请表
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:edit')")
    @Log(title = "分销员申请表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Distributorapp distributorapp)
    {
        return toAjax(distributorappService.updateDistributorapp(distributorapp));
    }

    /**
     * 删除分销员申请表
     */
    @PreAuthorize("@ss.hasPermi('distributorapp:distributorapp:remove')")
    @Log(title = "分销员申请表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(distributorappService.deleteDistributorappByIds(ids));
    }
}
